class ShareModel {
  // 基本属性
  late int? shareId;
  late int? deviceId;
  late int? userId;
  late int? toId;
  late String? startTime;
  late String? endTime;
  late int? shareType;
  late int? shareStatus;
  late int? authLock;
  late int? authTalk;
  late int? authMachine;
  late int? del;

  // 继承BaseEntity的属性（创建时间和更新时间）
  final String? createTime;
  final String? updateTime;

  ShareModel({
    this.shareId,
    this.deviceId,
    this.userId,
    this.toId,
    this.startTime,
    this.endTime,
    this.shareType,
    this.shareStatus,
    this.authLock,
    this.authTalk,
    this.authMachine,
    this.del,
    this.createTime,
    this.updateTime,
  });

  // 从JSON数据创建Share实例的工厂方法
  factory ShareModel.fromJson(Map<String, dynamic> json) {
    return ShareModel(
      shareId: (json['shareId'] as num?)?.toInt(),
      deviceId: (json['deviceId'] as num?)?.toInt(),
      userId: (json['userId'] as num?)?.toInt(),
      toId: (json['toId'] as num?)?.toInt(),
      startTime: json['startTime'] as String?,
      endTime: json['endTime'] as String?,
      shareType: (json['shareType'] as num?)?.toInt(),
      shareStatus: (json['shareStatus'] as num?)?.toInt(),
      authLock: (json['authLock'] as num?)?.toInt(),
      authTalk: (json['authTalk'] as num?)?.toInt(),
      authMachine: (json['authMachine'] as num?)?.toInt(),
      del: (json['del'] as num?)?.toInt(),
      createTime: json['createTime'] as String?,
      updateTime: json['updateTime'] as String?,
    );
  }

  // 将Share实例转换为JSON格式
  Map<String, dynamic> toJson() {
    return {
      'shareId': shareId,
      'deviceId': deviceId,
      'userId': userId,
      'toId': toId,
      'startTime': startTime,
      'endTime': endTime,
      'shareType': shareType,
      'shareStatus': shareStatus,
      'authLock': authLock,
      'authTalk': authTalk,
      'authMachine': authMachine,
      'del': del,
      'createTime': createTime,
      'updateTime': updateTime,
    };
  }

  @override
  String toString() {
    return 'ShareModel{'
        'shareId: $shareId, '
        'deviceId: $deviceId, '
        'userId: $userId, '
        'toId: $toId, '
        'startTime: $startTime, '
        'endTime: $endTime, '
        'shareType: $shareType, '
        'shareStatus: $shareStatus, '
        'authLock: $authLock, '
        'authTalk: $authTalk, '
        'authMachine: $authMachine, '
        'del: $del, '
        'createTime: $createTime, '
        'updateTime: $updateTime'
        '}';
  }
}
